#include <iostream>
#include <pthread.h>
#include <unistd.h>
using namespace std;

//新线程
void* run(void*args)
{
    while(true)
    {
        cout<<"new thread,pid:"<<getpid()<<endl;
        sleep(1);
    }
    return nullptr;
}

int main()
{
    cout<<"my pid:"<<getpid()<<endl;
    pthread_t tid;
    pthread_create(&tid,nullptr,run,(void*)"thread-1");
    //主线程
    while(true)
    {
        cout<<"main thread,pid:"<<getpid()<<endl;
        sleep(1);
    }
    return 0;
}